﻿using System;
using System.IdentityModel.Selectors;
using System.Linq;
using System.ServiceModel;
using BusinessLogicLibrary;

namespace ServiceLibrary
{
    internal class ManagerValidator : UserNamePasswordValidator
    {
        public override void Validate(string userName, string password)
        {
            string[] roles = Roles.ManagerRoles;

            if (userName == null || password == null)
            {
                throw new ArgumentNullException();
            }

            var authenticateModule = new AuthenticateModule();
            if (roles.Any(s => authenticateModule.UserCheck(userName, password, s, "Manager Service")))
            {
                return;
            }

            throw new FaultException("Incorrect Username or Password");
        }
    }
}